﻿@model List<Doan.Forum.Models.aspnet_Membership>         
@using Ext.Net
@using Ext.Net.MVC
@{
    ViewBag.Title = "List Account";
    Layout = "~/Views/Shared/_Layout_Admin.cshtml";
}
@section Header
{
    <script type="text/javascript">
        function getSelect() {
            var bt = confirm('Bạn có chắc chắn?');
            if (bt == true) {
                if (App.DataGridPanelAccount.getSelectionModel().getSelection()[0] == null) {
                    alert('Không có phần tử nào được chọn');
                    return;
                }
                var count = App.DataGridPanelAccount.getSelectionModel().getSelection().length;
                var mang = new Array();
                for (var i = 0; i < count; i++) {
                    mang[i] = App.DataGridPanelAccount.getSelectionModel().getSelection()[i].get('UserName');
                }
                App.direct.InActiveAccount(mang);
            }
        }
    </script>
}
@section ToolbarSection{
    @*@Html.X().Button().Text("Tạo mới").Icon(Icon.ControlAddBlue).Listeners(ls => ls.Click.Handler = "showWindow('Create Account','/Account/Register',true,1,1);")*@
}
@* GridPanel *@
@(Html.X().GridPanel().ID("DataGridPanelAccount")
        .Title("Danh sách tài khoản")
        .Icon(Icon.Table)
        .Frame(true)
        .TopBar(Html.X().Toolbar().ID("ToolID").Items(items =>
         {
             items.Add(new LinkButton { Text = "All", Handler = "#{DirectMethods}.CharFilterAccount('');", });

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "0-9", Handler = "#{DirectMethods}.CharFilterAccount('0');", });

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "A", Handler = "#{DirectMethods}.CharFilterAccount('A');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "B", Handler = "#{DirectMethods}.CharFilterAccount('B');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "C", Handler = "#{DirectMethods}.CharFilterAccount('C');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "D", Handler = "#{DirectMethods}.CharFilterAccount('D');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "E", Handler = "#{DirectMethods}.CharFilterAccount('E');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "F", Handler = "#{DirectMethods}.CharFilterAccount('F');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "G", Handler = "#{DirectMethods}.CharFilterAccount('G');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "H", Handler = "#{DirectMethods}.CharFilterAccount('H');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "I", Handler = "#{DirectMethods}.CharFilterAccount('I');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "J", Handler = "#{DirectMethods}.CharFilterAccount('J');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "K", Handler = "#{DirectMethods}.CharFilterAccount('K');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "L", Handler = "#{DirectMethods}.CharFilterAccount('L');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "M", Handler = "#{DirectMethods}.CharFilterAccount('M');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "N", Handler = "#{DirectMethods}.CharFilterAccount('N');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "O", Handler = "#{DirectMethods}.CharFilterAccount('O');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "P", Handler = "#{DirectMethods}.CharFilterAccount('P');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "Q", Handler = "#{DirectMethods}.CharFilterAccount('Q');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "R", Handler = "#{DirectMethods}.CharFilterAccount('R');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "S", Handler = "#{DirectMethods}.CharFilterAccount('S');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "T", Handler = "#{DirectMethods}.CharFilterAccount('T');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "U", Handler = "#{DirectMethods}.CharFilterAccount('U');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "V", Handler = "#{DirectMethods}.CharFilterAccount('V');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarSpacer());
             items.Add(new ToolbarSeparator());
             items.Add(new ToolbarSpacer());

             items.Add(new LinkButton { Text = "W", Handler = "#{DirectMethods}.CharFilterAccount('W');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "X", Handler = "#{DirectMethods}.CharFilterAccount('X');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "Y", Handler = "#{DirectMethods}.CharFilterAccount('Y');", });
             items.Add(new ToolbarSpacer());
             items.Add(new LinkButton { Text = "Z", Handler = "#{DirectMethods}.CharFilterAccount('Z');", });
             items.Add(new ToolbarSpacer());

             items.Add(new ToolbarFill());
             items.Add(new Button
             {
                 Text = "<b>Kích hoạt(Bỏ kích hoạt)</b>",
                 Margins = "0 20 0 0",
                 Icon = Icon.StopRed,
                 Handler = "getSelect();"
             });
             items.Add(new Checkbox
             {
                 FieldLabel = "Xem tất cả các phần tử",
                 Margins = "0 0 0 10",
                 LabelWidth = 130,
                 DirectCheckAction = "IncludeInActive"
             });
         }))

        .Store(Html.X().Store().ID("AccountStore")
            .Model(Html.X().Model().IDProperty("UserId")
                .Fields(
                    new ModelField("UserId", ModelFieldType.Int),
                    new ModelField("UserName", ModelFieldType.String),
                    new ModelField("Email", ModelFieldType.String),
                    new ModelField("CreateDate", ModelFieldType.Date),
                    new ModelField("Role", ModelFieldType.String),
                    new ModelField("IsApproved", ModelFieldType.Boolean)
                )
            )
                .RemoteSort(true)
                .RemotePaging(true)
                .PageSize(15)
                .Proxy(Html.X().AjaxProxy().Url(Url.Action("BindingStore"))
                                .Reader(Html.X().JsonReader().Root("data")))
        )
        .ColumnModel(
                    Html.X().Column().Text("Tên đăng nhập").DataIndex("UserName").Flex(1),
                    Html.X().Column().Text("Email").DataIndex("Email").Flex(1),
                    Html.X().Column().Text("Ngày tham gia").DataIndex("CreateDate").Flex(1),
                    Html.X().Column().Text("Loại thành viên").DataIndex("Role").Flex(1),
                    Html.X().Column().Text("Trạng thái kích hoạt").DataIndex("IsApproved").Flex(1),
                    Html.X().CommandColumn().Width(60).Commands(Html.X().GridCommand().CommandName("Edit").Icon(Icon.NoteEdit).Text("Cấp quyền Mod"))
                            .Listeners(ls => ls.Command.Handler = "App.direct.SetMod(record.data.UserName);").Flex(1),
                    Html.X().CommandColumn().Width(60).Commands(Html.X().GridCommand().CommandName("Edit").Icon(Icon.NoteEdit).Text("Cấp quyền Admin"))
                            .Listeners(ls => ls.Command.Handler = "App.direct.SetAdmin(record.data.UserName);").Flex(1)
        )
        .SelectionModel(Html.X().CheckboxSelectionModel().RowSpan(1))
        .BottomBar(Html.X().PagingToolbar())
)